package practice02;

import java.util.Scanner;

public class SumNum {
    public static void main(String[] args) {
        System.out.println("请输入自然数：");
        int a=new Scanner(System.in).nextInt();

        System.out.println(num(a));
    }

    private static int num(int a) {
        int sum=0;
        for (int i=1;;i++){
            if (a>=10){
                sum=sum+a%10;
                a=a/10;

            }else{
                int b=sum+a;
                return b;

            }
        }


    }
}
